package cn.middle.edge.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.middle.common.base.mapper.BaseMapper;
import com.middle.common.base.service.impl.BaseServiceImpl;
import com.middle.common.result.Page;

import cn.middle.edge.entity.Server;
import cn.middle.edge.mapper.ServerMapper;
import cn.middle.edge.service.ServerService;

@Service
public class ServerServiceImpl extends BaseServiceImpl<Server> implements ServerService {

	@Autowired
	private ServerMapper mapper;
	
	@Override
	public BaseMapper<Server> getDao() {
		return mapper;
	}
	@Override
	public Page<Server> listConditions(int page, int pageSize, String serviceId, String serviceName, Byte status) {
		PageHelper.startPage(page,pageSize);
		List<Server> servers = this.mapper.listConditions(serviceId, serviceName, status);
		return new Page<>(new PageInfo<>(servers));
	}
	
	@Override
	public boolean validateServerCode(String code) {
		return mapper.serverCodeNumber(code) == 0;
	}
}
